<template>
  <div>
    <puplic-modal
      width="1400px"
      :publicVisible="publicVisible"
      modalStyle="addEditSupportModal"
      @cancel="cancel"
      :title="title"
    >
      <div slot="content" class="content">
        <div class="search-group">
          <div class="input-wrap">
            <div class="label">所属行业:</div>
            <div class="input-item">
              <el-cascader
                clearable
                placeholder="请选择所属行业"
                class="cascader tradeCascader"
                v-model="industryCas"
                :show-all-levels="false"
                :options="industryListTree"
                :props="{ label: 'informationName', value: 'id' }"
                @change="handleCasChange"
              ></el-cascader>
            </div>
          </div>

          <div class="input-wrap">
            <div class="label">单位名称:</div>
            <div class="input-item">
              <a-input :maxLength="30" clearable v-model="queryParam.companyName" placeholder="请输入单位名称" />
            </div>
          </div>

          <div class="btn-wrap">
            <a-button class="searchBtn" @click="searchQuery(queryParam.startTime, queryParam.endTime)" type="primary">
              搜索
            </a-button>
            <a-button class="resetBtn" @click="searchReset()" type="primary"> 重置 </a-button>
          </div>
        </div>
        <div class="f1">
          <a-table
            rowKey="id"
            class="tableList"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            @change="handleTableChange"
          />
        </div>
      </div>
      <div slot="footer"></div>
    </puplic-modal>
  </div>
</template>
<script>
import puplicModal from '@/components/publicModal'
import { informationPage } from '@/api/industry'
import { Cascader } from 'element-ui'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { comMethods } from '@/mixins/comMethods'
import startEndTime from '@/components/startEndTime'
export default {
  components: { puplicModal, startEndTime, 'el-cascader': Cascader },
  mixins: [JeecgListMixin, comMethods],
  name: 'addEditSupportModal',
  data() {
    return {
      url: {
        list: '/sys/document_company/not_sign_company_page',
      },
      title: '未签署企业列表',
      publicVisible: false,
      disableMixinCreated: true,
      queryParam: {},
      industryCas: [],
      industryListTree: [],
      columns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '单位名称',
          dataIndex: 'companyName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '所属行业',
          dataIndex: 'industryInformationId_dictText',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '负责人',
          dataIndex: 'dutyPersonName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '联系电话',
          dataIndex: 'dutyMobile',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '所属辖区',
          dataIndex: 'policeJurisdictionId_dictText',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '责任民警',
          dataIndex: 'policeUserId_dictText',
          ellipsis: true,
          align: 'center',
        },
      ],
    }
  },
  methods: {
    async getDictCas() {
      let { result } = await informationPage()
      this.industryListTree = this.deleteChildren(result)
    },
    deleteChildren(arr) {
      let childs = arr
      for (let i = childs.length; i--; i > 0) {
        if (childs[i].children) {
          if (childs[i].children.length) {
            this.deleteChildren(childs[i].children)
          } else {
            delete childs[i].children
          }
        }
      }
      return arr
    },
    handleCasChange(e) {
      this.queryParam.industryInformationId = e.slice(-1).toString()
    },
    show(records) {
      this.queryParam.year = records.year
      this.queryParam.documentId = records.id
      this.title = '《' + records.documentName + '》' + this.title
      this.searchQuery()
      this.publicVisible = true

      this.industryCas = []
      this.getDictCas()
    },
    searchReset() {
      const { documentId, year } = this.queryParam
      this.industryCas = []
      this.queryParam = {}
      this.queryParam = { documentId, year }
      this.resetTime = true
      this.searchQuery()
    },

    cancel() {
      this.publicVisible = false
      this.title = '未签署企业列表'
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/common.less';

/deep/ .content {
  padding: 20px;
}

/deep/ .modalFooter {
  height: 0 !important;
}

/deep/ .ant-table-row-cell-ellipsis {
  cursor: pointer;
}

.search-group {
  padding: 0;
}
</style>
